package cn.ssdcc.dkserver.biz;

import cn.ssdcc.dkserver.entity.DkPath;
import cn.ssdcc.dkserver.mapper.ImMapper;
import cn.ssdcc.dkserver.mapper.MusicMapper;
import cn.ssdcc.dkserver.mapper.UserMapper;
import cn.ssdcc.dkserver.util.DownloadUtil;
import cn.ssdcc.dkserver.util.MusicToolUtil;
import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.File;

@Service
@Slf4j
public class CommonBiz {
    @Autowired
    MusicToolUtil musicToolUtil;

    @Autowired
    DownloadUtil downloadUtil;

    @Autowired
    MusicMapper musicMapper;

    @Autowired
    UserMapper userMapper;

    @Autowired
    ImMapper imMapper;

    @PostConstruct
    public void init() {
        musicMapper.createMusicTable();
        musicMapper.createMusicGroupTable();
        musicMapper.createMusicAndGroupTable();
        userMapper.createUserTable();
        userMapper.createThirdDevice();
        imMapper.createImMsg();
        try {
            File dir = new File(DkPath.DataPath);
            if(!dir.exists()){
                dir.mkdirs();//创建目录
                log.info("文件夹"+DkPath.DataPath+"创建成功");
            }
        } catch (Exception e) {
            log.error("文件夹"+DkPath.DataPath+"创建失败",e);
        }
    }
}
